//
//  LSEmotionButton.swift
//  新浪微博---01次
//
//  Created by 李宗帅 on 16/5/15.
//  Copyright © 2016年 LS. All rights reserved.
//

import UIKit

class LSEmoticonButton: UIButton {
    
    var emoticon: LSEmoticon?{
        
        didSet{
            
            
            if let png = emoticon?.png{
                
                let imageName = "\(emoticon!.package!)/\(png)"
                //                    printLog(imageName)
                self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
            } else {
                
                self.setImage(nil, forState: UIControlState.Normal)
                
            }
            
            
            // 实现以下 emoji
            if let emoji = emoticon?.emoji {
                
                // 有cod的才是 emoji
                
                // 打印的时候是一个字符串
                self.setTitle(emoji, forState: UIControlState.Normal)
                
            } else {
                
                self.setTitle(nil, forState: UIControlState.Normal)
                
            }
            
        }
        
    }
    
}

